﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
//using System.Windows.Forms;

static class HelperClass
    {
        public static string[] SplitOn(this string thingToBeSplit, string splitOnThis)
        {
            string[] pieces = Regex.Split(thingToBeSplit, splitOnThis);
            return pieces;
        }
        public static bool IsNullEmptyOrWhiteSpace(this string thingToCheck)
        {
            return String.IsNullOrEmpty(thingToCheck) || String.IsNullOrWhiteSpace(thingToCheck);
        }
        public static void PrintInColor(this string thingToPrint, ConsoleColor color)
        {
            Console.ForegroundColor = color;
            Console.WriteLine(thingToPrint);
            Console.ResetColor();
        }
        public static bool isInList<TElementOne>(this TElementOne item, List<TElementOne> list)
        {
            IEnumerable<TElementOne> array = list.Where(it => it.ToString().Equals(item.ToString()));
            return array.Count() > 0;
        }
        public static bool isASubDirectoryOf(this DirectoryInfo directory1, DirectoryInfo directory2)
        {
            bool isASub = false;
            foreach(DirectoryInfo dir in directory2.GetDirectories())
            {
                isASub = directory1.FullName.Equals(dir.FullName);
                if (isASub)
                    break;
            }
            return isASub;
        }
        //public static void Disable(this Button button)
        //{
        //    try
        //    {
        //        button.Enabled = false;
        //    }
        //    catch (Exception)
        //    {
        //    }
        //}
        //public static void Enable(this Button button)
        //{
        //    try
        //    {
        //        button.Enabled = true;
        //    }
        //    catch (Exception)
        //    {
        //    }
        //}
    }
